package my_web.service;
import dao.dao.impl.DaoFactory;
import my_web.Interface.UserInterface;
import my_web.bean.Emp;
import my_web.bean.User;
public class UserService implements UserInterface {
	public boolean checkUser(User user) {
		Boolean b=false;
		String username=user.getUsername();
		String password=user.getPassword();
		if(username!=null  && ! password.equals("")){
			String str=DaoFactory.getCurrDao().queryString("select *from Emp_table where e_id=? and password=?",username,password);
			if(str!=null){
				b=true;
			}
		}else{
			b=false;
		}
		return b;
	}
	public void modifyPwt(String pwt, String name) {
		DaoFactory.getCurrDao().update("update Emp_table set password=? where e_id=?",pwt,name);
	}
	public Emp queryEmpById(User user) {
		return DaoFactory.getCurrDao().queryBean(Emp.class, "select E.*,D.d_name,P.p_name from Emp_table E left join dep_table D on E.d_id=D.d_id left join pos_table P on E.p_id=P.p_id where E.e_id=?", user.getUsername());
	}
}
